<template></template>

<script>
import { exchange } from '@/api/login'
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
export default {
    name: 'callback',
    data() {
        return {}
    },
    mounted() {
        let token = this.$route.query.token
        exchange({ token: token, tenantCode: '' })
            .then((res) => {
                // if (res.data) {
                if (res.code === 200) {
                    console.log('token======', res)
                    setToken(res.data.access_token)
                    this.$store.commit('SET_TOKEN', res.data.access_token)
                    setExpiresIn(res.data.expires_in)
                    this.$store.commit('SET_EXPIRES_IN', res.data.expires_in)
                    this.$router.push('/index')
                } else {
                    this.$router.push('/login')
                }

                //     util.cookies.set('token', res.data)
                //     sessionStorage.setItem('isFull', true)
                //     this.$router.push('/index')
                // } else {
                //     this.$Message.warning('账号未登录!')
                //     setTimeout(() => {
                //         location.href =
                //             'http://platform.paas.gwm.cn/login?mode=TOKEN&redirect_url=http://10.6.99.157:1081/callback'
                //     }, 2000)
                // }
            })
            .catch((err) => {
                this.$router.push('/login')
            })
    },
    methods: {},
}
</script>

<style scoped>
</style>
